package org.example;


import java.io.IOException;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.Template;
import java.io.StringWriter;
import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;

/**
 * Hello world!
 */
public class App {

    public static void main(String[] args) throws Exception {

        VelocityEngine velocityEngine = new VelocityEngine();
        velocityEngine.setProperty("resource.loader.file.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
        velocityEngine.init();

        Template t = velocityEngine.getTemplate("t.vm");

        VelocityContext context = new VelocityContext();
        context.put("name", "World");

        StringWriter writer = new StringWriter();
//        t.merge(context, writer);
        velocityEngine.mergeTemplate("t.vm","UTF-8",context,writer);
        System.out.println(writer.toString());
    }
}
